package com.example.springmvcproject.Controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.example.springmvcproject.Service.Inteface.BankService;
import com.example.springmvcproject.Utils.ResultMessage;
import com.example.springmvcproject.Vo.BankSelectiveVo;
import com.example.springmvcproject.Vo.BankVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/bank")
@CrossOrigin
public class BankController {

    @Resource
    BankService bankService;

    /**
     * 添加银行卡名称
     * @param bankVo
     * @return
     */
    @SaCheckLogin
    @RequestMapping("/addBank")
    public ResultMessage addBank(@RequestBody @Validated BankVo bankVo){
        return bankService.addBank(bankVo);
    }

    @SaCheckLogin
    @RequestMapping("/selectBankByBankName")
    public ResultMessage selectBankByBankName(@RequestBody @Validated BankSelectiveVo bankSelectiveVo){

        return bankService.selectBankByBankName(bankSelectiveVo);
    }

    @SaCheckLogin
    @RequestMapping("/selectBanks")
    public ResultMessage selectBanks(){
        return bankService.selectBanksByUserId();
    }
    @SaCheckLogin
    @RequestMapping("/updateBankNameById")
    public ResultMessage updateBankNameById(@RequestBody @Validated BankVo bankVo){
        return bankService.updateBankNameById(bankVo);
    }
    @SaCheckLogin
    @RequestMapping("/deleteBankByIdAndName")
    public ResultMessage deleteBankByIdAndName(@RequestBody @Validated BankVo bankVo){
        return bankService.deleteBankByIdAndName(bankVo);
    }
}
